import * as React from "react";
import * as ReactDOM from "react-dom";

import "./AgentBlock.less";
import {AgentModel} from "../../../model/AgentModel";


export interface AgentBlockProps {
    item: AgentModel,
    type: string
}

export interface State {

}

export default class AgentBlock extends React.Component<AgentBlockProps, State> {
    //默认属性
    static readonly defaultProps: AgentBlockProps = {
        item: null,
        type: 'list',//list\share\review
    };

    constructor(props: AgentBlockProps) {
        super(props);
        //默认状态
        this.state = {};
    }

    //组件挂载后回调
    componentDidMount() {
        document.title = "";

    }

    render() {
        return <div className="agent-list-item">
            <div className="content">
                <strong>{this.props.item.title}</strong>
                <p>授权号:{this.props.item.number}</p>
                <p>代理级别:{this.props.item.level}</p>
                <p>状态:{this.props.item.status}</p>
            </div>
            <div className="btns">
                {this.props.type === 'list' ? <button className="btn btn-watch" onClick={() => {
                    location.hash = '#/certificate'
                }}>查看授权</button> : null}
                {this.props.type === 'review' ? <>
                    <div className="btn btn-agree">同意</div>
                    <div className="btn btn-disagree">拒绝</div>
                </> : null}
                {this.props.type === 'share' ? <>
                    <div className="btn btn-invite">邀请新代理</div>
                    <div className="btn btn-log" onClick={() => {
                        location.hash = '#/share-url-view-list'
                    }}>邀请记录
                    </div>
                </> : null}
            </div>
        </div>
    }
}
